#ifndef DEFENSE_H
#define DEFENSE_H

#include <QPainter>
#include <QStyleOptionGraphicsItem>
#include <QGraphicsItem>
#include "jeu.h"
#include <qmath.h>

class Jeu;

class Defense: public QGraphicsItem
{
protected:
    int compteur;
    int niveau;
    Jeu* jeu;
public:
    Defense(Jeu* jeu);
    virtual qreal portee() = 0;
    virtual qreal cadence() = 0;
    virtual qreal frappe() = 0;
    virtual const QColor& couleur() const = 0;
    virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    QRectF boundingRect() const { return QRectF(-64, -64, 128, 128); }
public slots:
    void advance(int phase);
};
class Eau : public Defense
{
public:
    Eau(Jeu* jeu);
    qreal portee() { return 2+niveau/2.0; }
    qreal cadence() { return 4-niveau/2.0; }
    qreal frappe() { return 5*qPow(niveau,1.5); }
    const QColor& couleur() const { return *new QColor(Qt::cyan); }
    static int getCout(int niveau);
};

class Pierre : public Defense
{
public:
    Pierre(Jeu* jeu);
    qreal portee() { return 3+niveau/2.0; }
    qreal cadence() { return 1; }
    qreal frappe() { return 100*qPow(niveau,1.5); }
    const QColor& couleur() const { return *new QColor(Qt::gray); }
    static int getCout(int niveau);
};
#endif // DEFENSE_H
